package com.webserver.http;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/*
记录所有HTTP协议相关规定内容
 */
public class HttpContext {
    private static Map<String,String> mineMapping= new HashMap<>();
    static {
        initMineMapping();
    }
    private static void initMineMapping(){
        Properties properties = new Properties();
        try {
            properties.load(
                    HttpContext.class.getResourceAsStream("web.properties")
            );
            properties.forEach(
                    (k,v)->mineMapping.put(k.toString(),v.toString())
            );
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    public static String getMineType(String ext){
        return mineMapping.get(ext);
    }

    public static void main(String[] args) {
        String type = getMineType("js");
        System.out.println(type);
    }
}
